package com.example.testkafka;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;

import java.util.*;
import java.util.concurrent.CountDownLatch;

@SpringBootApplication
public class TestkafkaApplication {

    public static void main(String[] args) {

        SpringApplication.run(TestkafkaApplication.class, args);
    }

//    @Bean
//    public ConcurrentKafkaListenerContainerFactory concurrentKafkaListenerContainerFactory() {
//
//        ConcurrentKafkaListenerContainerFactory<Integer, String> factory = new ConcurrentKafkaListenerContainerFactory<>();
//        factory.setConsumerFactory(consumerFactory());
//        factory.setConcurrency(3);// set to null to use single thread
//        factory.setBatchListener(true);// enable this when use batch listener
//        factory.getContainerProperties().setPollTimeout(3000);
//        return factory;
//    }
//
//    @Bean
//    public ConsumerFactory consumerFactory() {
//        return new DefaultKafkaConsumerFactory(consumerConfigs());
//    }
//
//    @Bean
//    public Map<String, Object> consumerConfigs() {
//
//        String brokerList = "192.168.92.101:9092,192.168.92.102:9092";
////        String groupId = "group.demo";
//
//        Map<String, Object> props = new HashMap<>();
//        props.put("key.deserializer","org.apache.kafka.common.serialization.StringDeserializer");
//        props.put("value.deserializer","org.apache.kafka.common.serialization.StringDeserializer");
//        props.put("bootstrap.servers",brokerList);
////        properties.put("group.id",groupId);
//        return props;
//    }
}

